package com.jecy.oauth.service;

import com.jecy.oauth.domain.UCMUserDetails;
import com.jecy.oauth.domain.User;
import com.jecy.utils.MD5Utils;
import org.springframework.security.core.userdetails.UserDetails;
import org.springframework.security.core.userdetails.UserDetailsService;
import org.springframework.security.core.userdetails.UsernameNotFoundException;
import org.springframework.stereotype.Service;

import java.util.HashMap;
import java.util.Map;

/**
 * Created by xjli on 15-7-23.
 */
@Service("autherUserService")
public class AutherUserService implements UserDetailsService {


    @Override
    public UserDetails loadUserByUsername(String userName) throws UsernameNotFoundException {

        Map<String, String> extraMap = CustomerContextHolder.getContextType();
        String plainPassword = extraMap.get("password");
        String product = extraMap.get("product");
        String appKey = extraMap.get("appKey");
        User user = new User();
        user.setAge("18");
        try {
            user.setPassWord(plainPassword);
        } catch (Exception e) {
            e.printStackTrace();
        }
        user.setUserName("张三");
        return new UCMUserDetails(user);
    }
}
